﻿using System;
using System.Windows;
using System.Windows.Controls;

namespace Net.Chirash.Twitter.TweetZone
{
    /// <summary>
    /// ConnectingIndicator.xaml の相互作用ロジック
    /// </summary>
    public partial class ConnectingIndicator : UserControl
    {
        #region Constructors

        public ConnectingIndicator()
        {
            this.InitializeComponent();
        }

        #endregion

        #region DependencyProperties

        public static readonly DependencyProperty StateProperty = DependencyProperty.Register("IsConnecting", typeof(Boolean),
                               typeof(ConnectingIndicator), new PropertyMetadata(false, new PropertyChangedCallback(OnIsConnectingChanged)));

        public Boolean IsConnecting
        {
            get
            {
                return (Boolean)this.GetValue(StateProperty);
            }
            set
            {
                this.SetValue(StateProperty, value);
            }
        }

        private static void OnIsConnectingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            //var visibility = ((ConnectingIndicator)d).Visibility;
            if ((bool)e.NewValue)
            {
                ((ConnectingIndicator)d).Visibility = Visibility.Visible;
            }
            else
            {
                ((ConnectingIndicator)d).Visibility = Visibility.Collapsed;
            }
        }

        #endregion
    }
}